function loginout() {
    $.ajax({
        type: 'POST',
        url: "user/loginout",
        dataType: "json",
        success: function (data) {
            location.href = "login.html";
        }
    });
}
//============================================= sweet titles// 鼠标提示，比如鼠标悬浮，显示提示

function ieShowTip(entity) {
	showTip(null, entity);
}

function showTip(e, entity) {
	var postResponsibility = entity.postResponsibility == null ? '' : entity.postResponsibility;
	var productionSituation = entity.productionSituation == null ? '' : entity.productionSituation;
	var security = entity.security == null ? '' : entity.security;
	var securityProduction = entity.securityProduction == null ? '' : entity.securityProduction;
	var leftProlem = entity.leftProlem == null ? '' : entity.leftProlem;
    var tooltip = '<div id="tooltip">' +
    		'<div class="panel">' + 
    			'<div class="banner">' +
                        '<h2 class="title" >值班信息&nbsp;&nbsp;</h2>' +                        
                        '<a class="exit"   onclick="closeTip();"></a>' +
                    '</div>' +
                    '<div class="content">' +
                      '<div class="body-bottom">' +
                          '<table class="table1" width="100%" height="510" border="0" cellpadding="0" cellspacing="0">' +
                                  '<tr>' +
                                        '<td width="164" height="50" align="center" valign="middle"> 个人信息</td>' +
                                        '<td width="738" align="center" valign="middle">' +
                                             '<table class="table2" width="738" border="0" cellspacing="0" cellpadding="0">' +
                                                      '<tr align="center" valign="middle">' +
                                                             '<td width="329" height="50">值班时间：' + entity.dutyTime + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;录入时间：' + entity.entryTime + '</td>' +
                                                             '<td width="219"></td>' +
                                                             '<td width="190">值班人：' + entity.dutyManFullName + '[' + entity.dutyMan + ']</td>' +
                                                      '</tr>' +
                                              '</table>' +
                                        '</td>' +
                            '</tr>' +
                            '<tr>' +
                              '<td height="86" align="center" valign="middle">生产情况及变动</td>' +
                              '<td class="content4 text">' + productionSituation + '</td>' +
                            '</tr>' +
                            '<tr>' +
                              '<td  height="86" align="center" valign="middle">安 全</td>' +
                              '<td class="content3 text">' + security + '</td>' +
                            '</tr>' +
//                            '<tr>' +
//                              '<td height="86" align="center" valign="middle">安全生产</td>' +
//                              '<td class="content2 text">' + securityProduction + '</td>' +
//                            '</tr>' +
                            '<tr>' +
                              '<td height="100" align="center" valign="middle">岗位责任制</td>' +
                              '<td align="center" valign="middle">' +
                                   '<table class="table3" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">' +
                                '<tr>' +
                                  '<td class="a" width="13%">劳动纪律及出勤情况</td>' +
                                  '<td class="d text" width="87%">' + postResponsibility + '</table>' +
                                  '</td>' +
                            '</tr>' +
                            '<tr>' +
                              '<td height="100" align="center" valign="middle">问题遗留整改</td>' +
                              '<td align="center" valign="middle">' +
                              '<table class="table4" width="100%"  height="100%"border="0" cellspacing="0" cellpadding="0">' +
                                '<tr>' +
                                  '<td class="b" width="13%" height="100%">班组反映的问题及整改情况</td>' +
                                  '<td  class="c text" width="87%">' + leftProlem + '</td>' +
                                '</tr>' +
                              '</table></td>' +
                            '</tr>' +
                          '</table>' +
                        '</div>' +
                         ' <div  height="34px">'+
                           '<div style="width:100px;float:right;padding-right:400px;"><a class="button round dark submit" onclick="closeTip();">返&nbsp;回</a></div>'+
                        '</div>'+
                      '</div>' +
                     
              	'</div>';
    tooltip += "</div>";
    $('body').append(tooltip);
    $('#tooltip .table1 td').css({
        "border": "1px solid #9EA3B2",
        "color": "#4B4E55"
    });
    $('#tooltip .table2 td').css({
        "border": "0px",
        "color": "red"
    });
    $('#tooltip')
        .css({
            "position": "absolute",
            "top": ($('#contont').offset().top + 10) + "px",
            "left": ($('#contont').offset().left + 260)  + "px"
        }).show('fast'); 
}

function closeTip() {
    $('#tooltip').remove();
}

function submit() {
	if ($('#dutyTime').datebox("getValue") == null || $.trim($('#dutyTime').datebox("getValue")) == "") {
		alert("值班时间不能为空！");
		return;
	}
	if ($('#entryTime').datebox("getValue") == null || $.trim($('#entryTime').datebox("getValue")) == "") {
		alert("录入时间不能为空！");
		return;
	}
    $.ajax({
        type: 'POST',
        url: "dutyrecord/add",
        data: { 
    		dutyTime : $('#dutyTime').datebox("getValue"),
    		entryTime : $('#entryTime').datebox("getValue"),
        	leftProlem : $('#leftProlem').val(),
        	postResponsibility : $('#postResponsibility').val(),
        	productionSituation : $('#productionSituation').val(),
        	security : $('#security').val(),
        	securityProduction : $('#securityProduction').val()
        },
        dataType: "json",
        success: function (data) {
        	if (data.result == 1) {
        		$.messager.alert("提示", "保存成功");
        		loadList();
        	} else {
        		$.messager.alert("提示", "保存失败");
        	}
        }
    });
}

function submitupdate() {
	if ($('#dutyTime').datebox("getValue") == null || $.trim($('#dutyTime').datebox("getValue")) == "") {
		alert("值班时间不能为空！");
		return;
	}
	if ($('#entryTime').datebox("getValue") == null || $.trim($('#entryTime').datebox("getValue")) == "") {
		alert("录入时间不能为空！");
		return;
	}
    $.ajax({
        type: 'POST',
        url: "dutyrecord/update",
        data: { 
    		id : $('#id').val(),
    		dutyMan : $('#dutyMan').val(),
    		dutyManFullName : $('#dutyManFullName').val(),
    		dutyTime : $('#dutyTime').datebox("getValue"),
    		entryTime : $('#entryTime').datebox("getValue"),
        	leftProlem : $('#leftProlem').val(),
        	postResponsibility : $('#postResponsibility').val(),
        	productionSituation : $('#productionSituation').val(),
        	security : $('#security').val(),
        	securityProduction : $('#securityProduction').val()
        },
        dataType: "json",
        success: function (data) {
        	if (data.result == 1) {
        		$.messager.alert("提示", "保存成功");
        		loadList();
        	} else {
        		$.messager.alert("提示", "保存失败");
        	}
        }
    });
}